<?php

require_once 'view/LoginView.php';
require_once 'view/LogView.php';
require_once 'model/LoginHandler.php';
require_once 'control/LoginController.php';
require_once 'control/MasterController.php';
require_once 'control/RegistrerController.php';
require_once 'model/UserHandler.php';
require_once 'model/ProductHandler.php';
require_once 'model/ShopBasketHandler.php';
require_once 'model/LogHandler.php';

session_start();

//skapa anslutning till databasen 
$DBConnection = new DBConnection;
  
//Anslut till databasen
$DBConnection -> Connect();

//nya instanser
// Produkt
$productHandler = new ProductHandler($DBConnection);
$shopBasketHandler = new ShopBasketHandler($DBConnection);

//LogIn
$loginHandler = new LoginHandler($DBConnection);
$UserHandler = new UserHandler($DBConnection);
$loginView = new LoginView();
$LoginController = new LoginController($loginHandler, $UserHandler, $productHandler, $shopBasketHandler);
$RegisterController = new RegisterController($UserHandler);
$MasterController = new MasterController($LoginController, $RegisterController);

$body = "";
// Ropar på metoden DoControll och skriver ut det som finns...
$body .= $MasterController -> DoControll();

//stäng databasuppkopplingen
$DBConnection->close();

//Testar om användaren är inloggad eller ej --------AVKOMMENTERA VID TEST------------------
/*
if ($loginHandler -> IsLoggedIn() == TRUE) {
			$body .= "Inloggad";
		} else {
			$body .= "Utloggad";
		}
*/
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<link rel="stylesheet" type="text/css" href="css/basic.css" title="default" />
		<script src="js/confirm.js"></script>
		<script src="js/buyconfirm.js"></script>
			<title>Figures4You</title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	</head>
	<body>
		<div id="container">
			<?php echo $body;?>
		</div>
		<script src="js/validate.js"></script>
	
	</body>
</html>